TableBatchapply

(批量)申请通过xml/tdr/proto文件新增表

申请加表接口支持在同一个业务的不同游戏区下添加多张表,其接口的cmd值为10002。

请求地址

POST
http://OmsAddress/app/newoms.php/webservice/business/table/batchapply?cmd=10002&ip-type=webservicerest&access-token=AccessTokenVal

POST请求参数说明

参数名称 数据类型 说明 是否必填字段 备注
app_id 整型 加表所在的业务id
attachment_id 数组 定义表结构的xml文件id列表
attention_man 字符串 用分号";"分隔关注人,关注人可执行此单据任务,字段最大长度为200
table_info 数组 table_info各数组项是在指定的app_id各zone下申请的加表信息,其数据结构见如下表格

申请加表时,table_info各数据项的结构:

zone_id 表所在的zone的id
tables 数组,数组中一个数据项是一张表的信息,表所填信息如右 参数名称 字段名称 数组类型 说明
table_name 表名称 字符串 长度1-31,只能包含字母、数字、下划线,首字母为字母、下划线
table_type 表类型 整型 0为generic,1为list 默认0
table_maxnum List最多元素个数 整型 table_type为1时,必填,范围1-10000
auto_approve_add_table_trans 是否自动审核此申请单 整型 若自动审核,需要加表所在的集群的权限允许
auto_execute_add_table_trans 是否自动执行此申请单对应的事务 整型 auto_approve_add_table_trans=1时,此处自动执行才有效,且需要加表所在的集群权限允许
compress 表压缩 整型 0不开启表压缩,1开启表压缩 默认1
calc_resource_type 计算表资源的模型 整型 1,简单模型;2,专家模式 默认1
active_record_num 活跃记录数 整型 calc_resource_type为1时必填,范围1-2147483647
total_record_num 总记录数 整型 calc_resource_type为1、2时必填
estimated_read_load 读频率 整型 calc_resource_type为1时必填
estimated_write_load 写频率 整型 calc_resource_type为1时必填
key_avarage_record_size 最大key大小 整型 calc_resource_type为1、2时必填
value_avarage_record_size Value平均大小 整型 calc_resource_type为1、2时必填
pcu 最高在线(PCU) 整型 calc_resource_type为2时必填
relationship_chain_interval 每玩家关系链读取间隔(秒) 整型 calc_resource_type为2时必填
relationship_chain_count 玩家关系链一次性读取记录条数(条) 整型 calc_resource_type为2时必填
index_count 索引/List数目 整型 calc_resource_type为2时必填
read_index_interval 每玩家索引/List读取间隔(秒) 整型 calc_resource_type为2时必填
read_index_count 平均每次索引/List读取时读取的记录条数(条) 整型 calc_resource_type为2时必填
read_interval 每玩家触发单条读取间隔(秒) 整型 calc_resource_type为2时必填
write_interval 每玩家触发单条写入间隔(秒) 整型 calc_resource_type为2时必填

Data参数

使用json格式表示记录相关信息,示例如下:

{
    "table_info": [
        {
            "tables": [
                {
                    "relationship_chain_count": 1,
                    "table_type": 0,
                    "compress": 0,
                    "value_avarage_record_size": 1,
                    "active_record_num": "2",
                    "total_record_num": "3",
                    "estimated_read_load": "4",
                    "read_index_interval": 60,
                    "index_count": 1,
                    "calc_resource_type": 2,
                    "write_interval": 60,
                    "pcu": 1,
                    "relationship_chain_interval": 60,
                    "table_name": "test_table_generic_modify",
                    "estimated_write_load": "5",
                    "key_avarage_record_size": 1,
                    "read_interval": 60,
                    "read_index_count": 1
                }
            ],
            "zone_id": "3"
        }
    ],
    "memo": "by auto test",
    "attachment_id": [
        99
    ],
    "app_id": "2"
}

返回说明

  1. http请求的Status为200,请求成功,返回加表信息;返回数据结构见“请求示例”
  2. http请求的Status 不等于200,请求失败,返回的数据为json格式,内容为错误信息描述 | |

请求示例

通过 curl 方法发起请求

命令中的参数请参考本页中的“POST请求参数说明”,access-token的获取方法详见:获取access-token

curl -H "Content-type: application/json" -X "POST" -d '{
    "table_info": [
        {
            "tables": [
                {
                    "relationship_chain_count": 1,
                    "table_type": 0,
                    "compress": 0,
                    "value_avarage_record_size": 1,
                    "active_record_num": "2",
                    "total_record_num": "3",
                    "estimated_read_load": "4",
                    "read_index_interval": 60,
                    "index_count": 1,
                    "calc_resource_type": 2,
                    "write_interval": 60,
                    "pcu": 1,
                    "relationship_chain_interval": 60,
                    "table_name": "test_table_generic_modify",
                    "estimated_write_load": "5",
                    "key_avarage_record_size": 1,
                    "read_interval": 60,
                    "read_index_count": 1
                }
            ],
            "zone_id": "3"
        }
    ],
    "memo": "by auto test",
    "attachment_id": [
        99
    ],
    "app_id": "2"
}' http://omsaddress/app/newoms.php/webservice/business/table/batchapply?cmd=10002&ip-type=webservicerest&access-token=<access-token>

返回示例

成功返回示例

http请求的Status=200,其中返回信息只需要关注ret是否0(0为成功)并拿到info信息中的id (单据id),检查app_id、zone_list、table_name是否对上即可,非特殊请情况其他字段无需过多关注。

[
    {
        "relationship_chain_count": 1,
        "table_type": 0, //表类型,0:generic;1:list
        "compress": 0,
        "value_avarage_record_size": 1,
        "active_record_num": "2",
        "total_record_num": "3",
        "estimated_read_load": "4",
        "read_index_interval": 60,
        "index_count": 1,
        "calc_resource_type": 2,
        "write_interval": 60,
        "pcu": 1,
        "relationship_chain_interval": 60,
        "table_name": "test_table_generic_modify",//表名称
        "estimated_write_load": "5",
        "key_avarage_record_size": 1,
        "read_interval": 60,
        "read_index_count": 1,
        "resource_ratio": 1,
        "zone_list": "3",//表所在的游戏区id
        "set_id": 126,//表所在的集群id
        "app_id": "2",//表所在的业务id
        "app_name": "t_app",
        "memo": "by auto test",
        "attention_man": "",
        "user": "tcaplus",
        "type": "xml",
        "apply_type": "0",
        "tdr": "99",
        "write_time": "2017-03-02 20:20:10",
        "dm_ratio": 5,
        "kelly_id": 0,
        "table_maxnum": 0,
        "trans_id":11524,//加表事务id
        "id": 108//加表申请单id 
    }
]

错误返回

http请求的Status!=200

[
    "ip(10.29.89.51) not in whitelist for applying to add table(cmd:10002) of set_id:126 app_id:2 zone_id:3"
]
{
    "name": "Unauthorized",
    "message": "you are not allowed to access this app:app_id:2",
    "code": 0,
    "status": 401,
    "type": "yii\\web ForbiddenHttpException"
}
[
    "table_name:已经申请其他表操作 app:2 zone:3 table_name:test_table_generic_modify apply id:108 apply type:{applytype} error type:{errortype}"
]
[
    "table_name:已经申请其他表操作 app:2 zone:3 table_name:test_table_generic_modify apply id:108 apply type:{applytype} error type:{errortype}"
]

results matching ""

    No results matching ""